<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>评审录单管理</title>
    <jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="fieldBox" id="searchPrjNmId">
                    <div class="label">项目名称</div>
                    <div class="field">
                        <input name="prjNm" id="prjNm" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox" id="searchCstNmId">
                    <div class="label">客户名称</div>
                    <div class="field">
                        <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox" id="searchCstMgrNmId" isyw="0">
                    <div class="label">客户经理名称</div>
                    <div class="field">
                        <input name="cstMgrNm" id="cstMgrNm" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox" id="searchUserNmId">
                    <div class="label">员工号</div>
                    <div class="field">
                        <input name="userNm" id="userNm" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox" id="searchPrjTypCdId">
                    <div class="label">项目类型</div>
                    <div class="field">
                        <input type="text" name="prjTypCd" id="prjTypCd" data-value="" placeholder="请选择" ltype="combobox">
                    </div>
                </div>

                <div class="fieldBox" id="searchCntTypCdId">
                    <div class="label">合同签署方式</div>
                    <div class="field">
                        <select name="cntTypCd"  id="cntTypCd"  >
                            <option value="  " selected="selected">--请选择--</option>
                            <c:forEach items="${cntTypCdList}" var="opt">
                                <option value="${opt.key}">${opt.value}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="fieldBox" id="searchBizTypCdId">
                    <div class="label">业务类型</div>
                    <div class="field">
                        <select name="bizTypCd"  id="bizTypCd"  >
                            <option value="  " selected="selected">--请选择--</option>
                            <c:forEach items="${bizTypeList}" var="opt">
                                <option value="${opt.key}">${opt.value}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="fieldBox col_33" id="searchPrjStsCdId">
                    <div class="label">项目状态</div>
                    <div class="field">
                        <select name="prjStsCd"  id="prjStsCd" >
                            <option value="  " selected="selected">--请选择--</option>
                            <c:forEach items="${prjStsList}" var="opt">
                                <option value="${opt.key}">${opt.value}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="fieldBox" id="searchLsCntNoId">
                    <div class="label">合同号</div>
                    <div class="field">
                        <input name="lsCntNo" id="lsCntNo" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox" id="searchBuOrgCdId">
                    <div class="label">所属事业部</div>
                    <div class="field">
                        <select name="buOrgCd" id="buOrgCd">
                            <option value=" " seleted>请选择</option>
                            <c:forEach items="${orgListList }" var="org">
                                <c:if test="${currentBuOrgCd == org.key }">
                                    <option value="${org.key }" selected>${org.value }</option>
                                </c:if>
                                <c:if test="${currentBuOrgCd != org.key }">
                                    <option value="${org.key }">${org.value }</option>
                                </c:if>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="fieldBox col_33" id="searchInsCodeId" <sys:resourceAuth resCd="noThdOrg">style="display: none" </sys:resourceAuth>>
                    <div class="label">第三方机构</div>
                    <div class="field">
                        <select name="insCode"  id="insCode" >
                            <option value="  " selected="selected">--请选择--</option>
                            <c:forEach items="${friBaseList}" var="fri">
                                <option value="${fri.insCode}">${fri.fundRasInsNm}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="fieldBox col_33" id="isDelId" >
                    <div class="label">是否删除</div>
                    <div class="field">
                        <select name="isDel"  id="isDel"  >
                            <option value="0"  selected="selected">否</option>
                            <option value="1">是</option>
                        </select>
                    </div>
                </div>
                <div class="fieldBox col_33" id="cstMgrOrgCdId" >
                    <div class="label">所属公司</div>
                    <div class="field">
                        <input name="cstMgrOrgCd" id="cstMgrOrgCd" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox col_33" >
                    <div class="label">创建时间</div>
                    <div class="field">
                        <input name="stDt" id="stDt" type="text" class="ui-datepicker" value="">
                        <span>---</span>
                        <input name="endDt" id="endDt" type="text" class="ui-datepicker" value="">
                    </div>
                </div>
                <div class="fieldBox col_33" id="isSplMfrDiv" >
                    <div class="label">是否厂商业务</div>
                    <div class="field">
                        <select name="isSplMfr"  id="isSplMfr"  >
                            <option value="  "  selected="selected">-请选择-</option>
                            <option value="0" >否</option>
                            <option value="1">是</option>
                        </select>
                    </div>
                </div>
                <div class="fieldBox col_33" id="isInsBizDiv" >
                    <div class="label">是否资管业务</div>
                    <div class="field">
                        <select name="isInsBiz"  id="isInsBiz"  >
                            <option value=" "  selected="selected">-请选择-</option>
                            <option value="0">否</option>
                            <option value="1">是</option>
                        </select>
                    </div>
                </div>
                <div class="fieldBox col_33" id="receiveStateId">
                    <div class="label">领取状态</div>
                    <div class="field">
                        <select name="receiveState"  id="receiveState"  >
                            <option value="  " selected="selected">--请选择--</option>
                            <c:forEach items="${receiveStateList}" var="opt">
                                <option value="${opt.key}">${opt.value}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="fieldBox" id="crtUsrNmId">
                    <div class="label">领取人</div>
                    <div class="field">
                        <input name="crtUsrNm" id="crtUsrNm" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="clearFix"></div>
                <div class="btnsBox">
                    <span id="searchBtn"  class="sq-button sq-button-round">查询</span>
                    <span id="clearBtn" onclick="clearBtn();" class="sq-button sq-button-round">清空</span>
                    <span id="flowStartBtn" class="sq-button sq-button-round" onclick="addFlowStart();">发起流程</span>
                </div>
                <!-- 隐藏客户ID, 提供给客户管理中 项目列表使用 -->
                <div class="fieldBox col_100" style="display:none;">
                    <div class="field">
                        <input name="cstId" id="cstId" type="text" class="ui-textbox" value="${cstId}">
                        <input name="cstNmNm" id="cstNmId" type="text" class="ui-textbox" value="${cstNm}">
                        <!-- 流程跟踪 隐藏选中数据项目ID -->
                        <input name="projectId" id="projectId" type="text" class="ui-textbox" value="">
                    </div>
                </div>
            </div>
        </form>
    </div>
    <div class="sqPanel" style="margin-bottom: 0;">
        <div class="sqPanel_head" style="float:left;color: red">
            <table class="table_full">
                <tr>
                    <td>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><i class="ico_flasher"></i></b>仅支持近一年内的数据查询
                    </td>
                </tr>
            </table>
        </div>
        <div id="ligergrid1" class="sq-grid"></div>
    </div>
</div>
<script type="text/javascript">
    var _usrId = '${currentUsrId}';//当前用户ID
    var grid = null;
    var callback = null;
    $(function () {
        initOrgTree();
        $("#ligergrid1").ligerGrid({
            url: '<%=path%>/audit/audStandingBook/initRevRecList.do',
            method : 'get',
            parms:{
                bookTypeCd: "6",
            },
            columns: [
                { display: '项目名称', name: 'prjNm', align:'left',minWidth: 140 ,
                    render: function (rowdata, rowindex, value, column) {
                        var h = '';
                        if(value&&value!="null"){
                            h+='<a href="javascript:prjDetailBtn(';
                            h+="'"+rowdata.prjId+"',";
                            h+=')">'+value+'</a>'
                        }
                        return h;
                    },
                    enabledSort:true},
                { display: '合同号', name: 'lsCntNo', minWidth: 140 , enabledSort:true},
                { display: '客户', name: 'cstNm', minWidth: 140,align:'center', enabledSort:true},
                { display: '客户经理', name: 'cstMgrNm', minWidth: 140,align:'center', enabledSort:true},
                { display: '所属机构', name: 'buOrgCdNm', width: 100 , enabledSort:true},
                { display: '省公司', name: 'prOrgCdNm', width: 100 , enabledSort:true},
                { display: '分公司', name: 'cyOrgCdNm', width: 100 , enabledSort:true},
                { display: '项目类型', name: 'prjTypCdNm', width: 150, enabledSort:true},
                { display: '是否资管业务', name: 'isInsBiz', minWidth: 100 , enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        if (rowdata.isInsBiz == 1) {
                            return "是";
                        } else if (rowdata.isInsBiz == 0) {
                            return "否";
                        }
                    }
                },
                { display: '是否厂商业务', name: 'isSplMfr', minWidth: 100 , enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        if (rowdata.isSplMfr == 1) {
                            return "是";
                        } else if (rowdata.isSplMfr == 0) {
                            return "否";
                        }
                    }
                },
                { display: '业务模式', name: 'bizTypCdNm', minWidth: 140 , enabledSort:true},
                { display: '项目状态', name: 'prjStsCdNm', minWidth: 100 , enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        if (rowdata.prjTypCd == "LCV" && rowdata.prjStsCd.startsWith("900")) {
                            return "待提交";
                        } else {
                            return rowdata.prjStsCdNm;
                        }
                    }},
                { display: '领取状态', name: 'receiveStateNm', minWidth: 100 , enabledSort:true},
                { display: '发送时间', name: 'crtTm', minWidth: 100 , render:renderDateDetail, enabledSort:true},
                { display: '领取时间', name: 'receiveTm', minWidth: 100 , render:renderDateDetail, enabledSort:true},
                { display: '提交时间', name: 'pCrtTm', minWidth: 100 , render:renderDateDetail, enabledSort:true},
                { display: '领取人', name: 'crtUsrNm', minWidth: 100 , enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        if (rowdata.receiveState == "1") {
                            return null;
                        } else {
                            return rowdata.crtUsrNm;
                        }
                    }
                },
                getOptColumn()
            ],
            pageSize:10,
            root:'rows',
            record:'total',
            hideLoadButton : true,
            width: '100%',
            height:'100%',
            heightDiff:-20,
            checkbox:true,
            delayLoad:true,
            rownumbers:true,
            onSelectRow: function(rowdata, rowid, rowobj){
                if (rowdata.crtUsrId == _usrId && rowdata.receiveState != "1") {
                    $("#flowStartBtn").show();
                }else {
                    $("#flowStartBtn").hide();
                }
            }
        });
        grid = liger.get("ligergrid1");
        grid.setHeight(100);

        var _prjTypCdList = ${projectTypeList};
        $("#prjTypCd").ligerComboBox({
            isShowCheckBox: true,
            isMultiSelect: true,
            data: _prjTypCdList,
            valueField: 'key',
            textField: 'value'
        });
        $("#searchBar").ligerForm();
        //查询
        $("#searchBtn").click(function(event) {
            var form = new liger.get("searchBar");
            var data = form.getData();
            for (name in data){
                grid.setParm(name,data[name]);
            };
            if(StringUtils.isNotEmpty($("#stDt").val()) && StringUtils.isNotEmpty($("#endDt").val()) && $("#stDt").val()>$("#endDt").val()){
                $.ligerDialog.SQalert({content: "创建日期(起)不能大于创建日期(止)" , SQ_type: "warning" });
                return;
            }
            var date1 = new Date();
            date1.setFullYear(date1.getFullYear()-1);
            date1.setDate(date1.getDate() + 1);
            if (StringUtils.isEmpty($("#stDt").val())){
                grid.setParm("stDt",DateUtils.formatDate(date1,DateUtils.YYYY_MM_DD));
            }
            var flag = false;
            if (StringUtils.isNotEmpty($("#stDt").val()) && $("#stDt").val() < DateUtils.formatDate(date1,DateUtils.YYYY_MM_DD)){
                flag = true;
            }
            if (StringUtils.isNotEmpty($("#endDt").val()) && $("#endDt").val() < DateUtils.formatDate(date1,DateUtils.YYYY_MM_DD)){
                flag = true;
            }
            if (flag){
                top.$.ligerDialog.SQalert({content: "仅支持查询创建时间至今一年内数据",SQ_type: "success"});
                grid.setParm("stDt",DateUtils.formatDate(date1,DateUtils.YYYY_MM_DD));
            }
            grid.reload();
        });

        var form = new liger.get("searchBar");
        var data = form.getData();
        for (name in data){
            grid.setParm(name,data[name]);
        };
        grid.reload();
        $("#pageloading").hide();

        //清空
        $("#clearBtn").click(function(){
            $("#searchBar").ligerForm();
            var form = new liger.get("searchBar");
            form.setData({
                prjNm:" ",
                cstNm:" ",
                prjTypCd:" ",
                bizTypCd:" ",
                prjStsCd:" ",
                orgCd:" ",
                crtUsrNm: " ",
                lsCntNo:" ",
                cstMgrNm:"",
                cntTypCd:" ",
                isSplMfr:" "
            });
        })

    });


    function initOrgTree(){
        var params = {};
        params.cstMgrOrgCd = '${currOrg}';
        searchOrgTree = $("#cstMgrOrgCd").ligerComboBox({
            width: 480,
            selectBoxWidth: 480,
            selectBoxHeight: 150,
            //限制只能选叶节点，父节点不能点击
            treeLeafOnly: false,
            valueField: 'orgCd',
            textField: 'orgDispNm',
            showTreePath: true,
            tree: {
                ajaxType: 'get',
                idFieldName:'orgCd',
                textFieldName: 'orgDispNm',
                checkbox: false,
                parentIcon: "none",
                childIcon: "none",
                needCancel : false
            }
        });
        $.ajax({
            type: 'get',
            dataType:'json',
            data: params,
            url: '<%=path%>/project/prjbscinfo/searchBuOrgTree.do',
            success:function(msg){
                if(msg.success == 1){
                    searchOrgTree.treeManager.setData(msg.data);
                    searchOrgTree.clear();
                    searchOrgTree.setValue('${currOrg}');
                }else{
                    $.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
                }
            }
        });

    }

    //获取操作列
    function getOptColumn(){
        var column = {
            display: '操作',
            isSort: false,
            width: 300,
            align:'left',
            render: function (rowdata, rowindex, value){
                var h="";
                if (rowdata.receiveState == "1" && ("0" == rowdata.prjStsCd || rowdata.prjStsCd.startsWith("900"))) {
                    h+='<a class="sq-button-hasicon" href="javascript:receive(';
                    h+="'"+rowdata.id+"',";
                    h+="'"+rowdata.prjId+"'";
                    h+=')"><i class="sqBtnIco_4"></i>领取</a>'
                }
                if (rowdata.receiveState == "2" && rowdata.crtUsrId == _usrId && ("0" == rowdata.prjStsCd || rowdata.prjStsCd.startsWith("900"))) {
                    var id = rowdata.prjId;
                    h+='<a class="sq-button-hasicon" href="javascript:modifyBtn(';
                    h+="'"+ id +"'";
                    h+=')"><i class="sqBtnIco_4"></i>修改</a>';
                    h+='<a class="sq-button-hasicon" href="javascript:audRemainPro(';
                    h+="'"+ rowdata.id +"'";
                    h+=')"><i class="sqBtnIco_4"></i>遗留问题</a>'

                }
                return h;
            }
        }
        return column;
    }

    //格式化时间
    function renderDateDetail(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
        }
        return dateStr;
    }

    function modifyBtn(id){
        var callback = function(){
            grid.reload();
        }
        //查询参数
        var detailFlag = false;
        // 客户经理修改flag
        var fromCMFlag = true;
        var params = "?id="+id+"&detailFlag="+detailFlag + "&fromCMFlag=" + fromCMFlag;
        //如果客户ID存在则加入参数
        var _cstId = $("#cstId").val();//客户ID
        var _cstNm = $("#cstNmId").val();//客户名称
        if(StringUtils.isNotEmpty(_cstId)){
            params+= "&cstId="+_cstId+"&cstNm="+_cstNm
        }
        Add_navTab('tab_prj_bsc_info_add'+id,'修改项目信息','<%=path%>/project/prjbscinfo/toModifyPage.do'+params,callback);
    }

    function audRemainPro(id){
        var callback = function(){
            grid.reload();
        }
        $.ligerDialog.SQopen({
            width: 800,
            height:300,
            title : '信审员遗留问题',
            url:'<%=path%>/audit/audStandingBook/toAudRemainProPage.do?id='+id,
        });
    }

    //领取后修改领取状态为录入中
    function receive(id,prjId){
        if(!id)return;
        $.ligerDialog.SQconfirm('确定领取吗？', function (yes) {
            if(yes == false){
                return;
            }
            $.ajax({
                type: 'post',
                dataType:'json',
                data: {
                    id: id,
                    receiveState:"2",
                    bookTypeCd:"6",
                    prjId: prjId
                },
                url: '<%=path%>/audit/audStandingBook/modifyReceiveState.do' ,
                success:function(msg){
                    if(msg.success == 1){
                        top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
                        grid.reload();
                    }else{
                        top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
                    }
                }
            });
        });
    }

    function prjDetailBtn(id){
        var detailFlag = true;
        Add_navTab('tab_project_detail'+id,'项目详情','<%=path%>/project/prjbscinfo/toModifyPage.do?id='+id+'&&detailFlag='+detailFlag);
    }

    // 自定义按钮文本
    $.ligerDefaults.ButtonStrings = {
        yes: '是',
        onlyHTCity: '否,仅发起城配流程',
        onlyAP: '否,仅发起提前放款'
    };
    // 自定义按钮的弹出框
    function expatriateFlowDialog (content, title, callback, left, right)
    {
        if (typeof (title) == "function")
        {
            callback = title;
            type = null;
        }
        var btnclick = function (item, Dialog)
        {
            Dialog.close();
            if (callback)
            {
                callback(item.type == 'ok');
            }
        };
        p = {
            type: 'question',
            content: content,
            buttons: [
                {
                    text: left, onclick: btnclick, type: 'ok', cls: 'l-dialog-btn-ok'
                }, {
                    text: right, onclick: btnclick, type: 'no', cls: 'l-dialog-btn-no'
                }
            ]
        };
        if (typeof (title) == "string" && title != "") p.title = title;
        $.extend(p, {
            showMax: false,
            showToggle: false,
            showMin: false,
            width: 300,
            height: 100

        });
        return $.ligerDialog(p);
    };

    //2017-4-7 发起流程
    function addFlowStart(flowTypeKey){
        // flowTypeKey 0:原流程 1:随州外派
        if (typeof (flowTypeKey) == "undefined" || flowTypeKey == null) {
            flowTypeKey = 0;
        }
        var selectedRows = grid.getSelectedRows();
        if (selectedRows.length != 1) {
            $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warning"});
            return;
        }
        var prjStsCd = selectedRows[0].prjStsCd;//项目状态
        // 项目外派流程通过后，可发起项目评审流程
        var pNoNm = selectedRows[0].pNo;
        var isExpFlowPass = false;
        if (null != pNoNm && "" != pNoNm && pNoNm.indexOf("项目外派") != -1) {
            isExpFlowPass = true;
        }
        if(prjStsCd=="1" || prjStsCd=="4" || prjStsCd=="5" || prjStsCd=="6"){
            $.ligerDialog.SQalert({content: "项目审核中,不允许多次发起流程.", SQ_type: "warning"});
            return;
        }else if(prjStsCd=="2" && flowTypeKey == 0 && isExpFlowPass == false){
            $.ligerDialog.SQalert({content: "项目审核通过,不允许再次发起流程.", SQ_type: "warning"});
            return;
        }else if(prjStsCd=="3"){
            $.ligerDialog.SQalert({content: "项目审核不通过,不允许再次发起流程.", SQ_type: "warning"});
            return;
        }
        var prjTypCd = selectedRows[0].prjTypCd;//项目类型
        if('CDDYW' === prjTypCd){
            $.ligerDialog.SQalert({content: "车抵贷业务不支持手动发起流程.", SQ_type: "warning"});
            return;
        }

        //客户主要信息变更流程中不允许发起项目评审流程-BUG-5717
        var cstId = selectedRows[0].cstId; //客户ID
        if(checkCstModFlow(cstId) == 1){
            return;
        }

        // 项目类型：车抵贷业务线下，校验规则如下：所有车辆都必须增加车牌号；必须有一台车的车牌号是征信结果有效的车牌号
        if ('CDDYWUL' === prjTypCd) {
            console.log("项目类型:"+ prjTypCd)
            var f = 0;
            var info = "";
            var prjId = selectedRows[0].prjId;
            console.log("车抵贷业务线下，发起流程PrjId: " + prjId);
            $.ajax({
                type: 'get',
                dataType: 'json',
                async: false,
                url: '<%=path%>/project/prjprddtl/modifyVehNo.do?prjId=' + prjId,
                success: function (data) {
                    if (data.success == 0) {
                        info = data.info;
                        f = 1;
                    }
                }
            });
            if (f == 1){
                $.ligerDialog.SQalert({content: info, SQ_type: "warning"});
                return;
            }
        }

        // 发起流程弹窗校验
        var expatriateFlowAuth = false;
        console.log("项目类型->" + prjTypCd);
        if (flowTypeKey != 1 && ('CPYW' === prjTypCd || 'DSFZGCP' === prjTypCd || 'CSYWCP' === prjTypCd)) {
            // 弹窗：是否同时发起随州垫款流程
            $.ajax({
                type: 'post',
                dataType: 'json',
                async: false,
                data: {
                    prjId: selectedRows[0].prjId
                },
                url: '<%=path%>/project/audit/checkExpatriateFlowAuth.do?',
                success: function (data) {
                    if (data.success == 1) {
                        // 可发起，垫款弹窗
                        expatriateFlowAuth = true;
                    }
                }
            });
        }
        var startExpatriateFlow = 0;
        // 可发起
        if (expatriateFlowAuth) {
            expatriateFlowDialog (FlowConstant.EXPATRIATE_FLOW_ADD_START_CONFIRM, '提示', function (flag) {
                if (flag == true) {
                    // 发起垫款标识
                    startExpatriateFlow = 1;
                    // 发起流程确认
                    addFlowStartConfirm(selectedRows, flowTypeKey, startExpatriateFlow);
                } else {
                    // 发起流程确认
                    addFlowStartConfirm(selectedRows, flowTypeKey, startExpatriateFlow);
                }
            }, $.ligerDefaults.ButtonStrings.yes, $.ligerDefaults.ButtonStrings.onlyHTCity);
        } else {
            $.ligerDialog.confirm(FlowConstant.FLOW_ADD_START_CONFIRM, function (flag) {
                if (flag == false) {
                    return;
                } else {
                    // 发起流程确认
                    addFlowStartConfirm(selectedRows, flowTypeKey, startExpatriateFlow);
                }
            });
        }
    }

    function addFlowStartConfirm(selectedRows, flowTypeKey, startExpatriateFlow) {
        var prjId = selectedRows[0].prjId;
        // 在项目流程发起的同时，发起供应商账号、供应商返利账号、销售返利账号的流程（如果账号审核状态是未提交和未通过的前提下）huangkailun
        $.ajax({
            type: 'get',
            dataType:'json',
            async: false,
            url: '<%=path%>/project/prjbscinfo/queryAccStsAndGetFlowParams.do?prjId='+prjId,
            success:function(data){
                if(data.success == 1){
                    var splFLow = data.data.splFlow;
                    var splBackFlow = data.data.splBackFlow;
                    var saleRebAccFlow = data.data.saleRebAccFlow;
                    if (splFLow == 'spl') {
                        $.ajax({
                            type: 'post',
                            dataType:'json',
                            async: false,
                            data:{
                                id:data.data.splId,
                                procDefKey:data.data.splProcDefKey,
                                procDefId:data.data.splProcDefId,
                                procNo:data.data.splProcNo,
                                modelTyp:data.data.splModelTyp
                            },
                            url: '<%=path%>/commonBankAcc/flow/startAccessFlow.do',
                            success:function(data){

                            }
                        });
                    }
                    if (splBackFlow == 'splBack'){
                        $.ajax({
                            type: 'post',
                            dataType:'json',
                            async: false,
                            data:{
                                id:data.data.splBackId,
                                procDefKey:data.data.splBackProcDefKey,
                                procDefId:data.data.splBackProcDefId,
                                procNo:data.data.splBackProcNo,
                                modelTyp:data.data.splBackModelTyp
                            },
                            url: '<%=path%>/commonBankAcc/flow/startAccessFlow.do',
                            success:function(data){

                            }
                        });
                    }
                    if (saleRebAccFlow == 'saleRebAcc') {
                        $.ajax({
                            type: 'post',
                            dataType:'json',
                            async: false,
                            data:{
                                id:data.data.saleRebAccId,
                                procDefKey:data.data.saleRebAccProcDefKey,
                                procDefId:data.data.saleRebAccProcDefId,
                                procNo:data.data.saleRebAccProcNo,
                                modelTyp:data.data.saleRebAccModelTyp
                            },
                            url: '<%=path%>/commonBankAcc/flow/startAccessFlow.do',
                            success:function(data){

                            }
                        });
                    }

                }
            }
        });

        var wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting",onClose: function () {}});
        var isOk = true;//是否验证通过
        //验证客户风险状态
        <%--$.ajax({--%>
        <%--    type: 'get',--%>
        <%--    dataType:'json',--%>
        <%--    async: false,--%>
        <%--    &lt;%&ndash;url: '<%=path%>/risk/rskCstSignLog/searchRskSts.do?prjId='+selectedRows[0].prjId,&ndash;%&gt;--%>
        <%--    url: '<%=path%>/project/audit/checkRiskSign.do?flow=PRJ&prjId='+selectedRows[0].id,--%>
        <%--    success:function(data){--%>
        <%--        wait_dialog.close();--%>
        <%--        if(data.success != 1){--%>
        <%--            $.ligerDialog.SQalert({content: data.info, SQ_type: "error",SQ_showButtons : true});--%>
        <%--            isOk = false;--%>
        <%--        }--%>
        <%--    }--%>
        <%--});--%>
        if(!isOk){
            return;
        }
        //浙商校验四要素是否验证通过
        if(selectedRows[0].insCode=='czbank'){
            $.ajax({
                type: 'get',
                dataType:'json',
                async: false,
                url: '<%=path%>/project/prjCstAccInfo/searchAccInfoByPrjId.do?prjId='+selectedRows[0].prjId,
                success:function(data){
                    wait_dialog.close();
                    if(data.success != 1){
                        $.ligerDialog.SQalert({content: data.info, SQ_type: "error",SQ_showButtons : true});
                        isOk = false;
                    }
                }
            });
        }
        //判断是否验证通过
        if(!isOk){
            return;
        }

        $.ajax({
            type: 'post',
            dataType:'json',
            url: '<%=path%>/project/audit/lnkCompAud.do?prjId='+prjId,
            success:function(data){
                if(data.success == 1){
                    $.ajax({
                        type: 'post',
                        dataType:'json',
                        url: '<%=path%>/project/audit/addFlowStart.do?prjId='+prjId+'&flowTypeKey='+flowTypeKey+'&startExpatriateFlow='+startExpatriateFlow+'&isRecoderStartFlow=1',
                        success:function(msg){
                            wait_dialog.close();
                            if(msg.success == 1){//成功发起流程
                                UIUtils.alertSuccessHold1(msg.info);
                                grid.reload();
                            }else if(msg.success == 0){//错误
                                UIUtils.alertErrorHold1(msg.info);
                            }else if(msg.success ==2){//找到多个流程
                                //TODO
                                console.log(msg.data);
                                var __DATA_radioList = msg.data;
                                var selectedVal = '';
                                var selectDialog = $.ligerDialog.SQopen({
                                    width: 300,
                                    height: 200,
                                    title : '请选择要发起的流程',
                                    allowClose: false,
                                    content: '<div id="radiolist1"></div>',
                                    fixButtons: true, //固定按钮到底部
                                    onOk: function () {
                                        console.log(selectDialog);
                                        console.log(selectedVal);
                                        if(StringUtils.isEmpty(selectedVal)){
                                            $.ligerDialog.SQalert({content: "请选择要发起的流程.", SQ_type: "warning"});
                                            return;
                                        }else{
                                            selectDialog.close();
                                            var wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting",onClose: function () {}});
                                            $.ajax({
                                                type: 'post',
                                                dataType:'json',
                                                url: '<%=path%>/project/audit/addFlowStart.do?prjId='+prjId+'&procDefKey='+selectedVal+'&startExpatriateFlow='+startExpatriateFlow,
                                                success:function(msg){
                                                    wait_dialog.close();
                                                    if(msg.success == 1){//成功发起流程
                                                        UIUtils.alertSuccessHold1(msg.info);
                                                        grid.reload();
                                                    }else if(msg.success == 0){//错误
                                                        UIUtils.alertErrorHold1(msg.info);
                                                    }
                                                }
                                            })
                                        }
                                    }
                                });
                                $("#radiolist1").ligerRadioList({
                                    data: __DATA_radioList,
                                    textField: 'procNm',
                                    valueField: 'procDefKey',
                                    rowSize: 1,
                                    onSelect: function (data)
                                    {
                                        console.log(data);
                                        selectedVal = data.value;
                                    }
                                });
                            }
                        }
                    });
                }else{
                    wait_dialog.close();
                    $.ligerDialog.SQalert({content: data.info, SQ_type: "warning"});
                    return;
                }
            }
        });
    }

    function iframeResize () {
        if (parent.mainApp) {
            parent.mainApp.parentTab.onResize();
        }
    }

    //判断该客户是否存在状态为"审核中"的《客户主要信息变更流程》
    function checkCstModFlow(_cstId){
        var cFlag = 0;
        var params = {cstId:_cstId};
        var _url = '<%=path%>/customer/cstbscinfo/checkCstModFlow.do';
        $.ajax({
            type:'get',
            dataType:'json',
            async:false,
            url:_url,
            data:params,
            success:function(msg){
                if(msg.success == 1){//存在-不支持立项和评审
                    cFlag = 1;
                    UIUtils.alertWarning(msg.info);
                }else if(msg.success == 0){//不存在-可以立项和评审
                    cFlag = 0;
                }
            },
            error:function(msg){
                UIUtils.alertError(msg.info);
            }
        });
        return cFlag;
    }
</script>

</body>
</html>